package com.envmonitor.domain.repository;

import com.envmonitor.domain.model.EnvironmentData;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDateTime;
import java.util.List;

public interface EnvironmentDataRepository extends JpaRepository<EnvironmentData, Long> {
    List<EnvironmentData> findByDeviceId(Long deviceId);
    
    List<EnvironmentData> findByRecordedAtBetween(LocalDateTime start, LocalDateTime end);
    
    @Query("SELECT e FROM EnvironmentData e WHERE e.temperature > ?1")
    List<EnvironmentData> findByTemperatureGreaterThan(Double temperature);
    
    @Query("SELECT e FROM EnvironmentData e WHERE e.humidity > ?1")
    List<EnvironmentData> findByHumidityGreaterThan(Double humidity);
    
    @Query("SELECT e FROM EnvironmentData e WHERE e.energyConsumption > ?1")
    List<EnvironmentData> findByEnergyConsumptionGreaterThan(Double energyConsumption);
}